<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:i18n="http://genshi.edgewall.org/i18n">
  <xi:include href="layout.html" />

  <!--! Note: the wiki edit page can be presented according to several modes:

        - "standard" or "side  by side" edit mode (`sidebyside` is true in the second mode)
          In standard mode, the edit area is on top of the preview, in side by side mode
          there are next to each other.

        - "edit" or "edit+preview" mode (`action == 'preview'` is true in the second mode)
          In edit mode, only the textarea is visible, but not the preview.
          In sidebyside mode, we always have a preview.
          In this category, we also have the "collision mode" (`action == 'collision'`),
          which happens when a concurrent edit has been detected.

        - "wiki preview" or "diff preview" (`diff` is true in the second mode)
          When the preview is shown, it can be either an actual preview of the rendered wiki
          text, or it can be a diff view on the changes that have been made (a.k.a. "review mode").
          In the latter case, `changes[0].diffs` contains the data for the diffs, if any.
          See `preview_or_review` below.
    -->
  <head>
    <title>$title</title>
    <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />
    <script type="text/javascript">
      jQuery(document).ready(function($) {
        $("#text").blur(function() {
          $("#scroll_bar_pos").val(this.scrollTop);
        }).get(0).scrollTop = $("#scroll_bar_pos").val();
        $("#editrows").change(function() {
          resizeTextArea("text", this.options[this.selectedIndex].value);
        });
        <py:if test="not sidebyside and (action == 'preview' or diff)">
          $("#info").scrollToTop();
        </py:if>
        <py:if test="sidebyside">
          function autoResizeText() {
            var preview_height = $("#preview").height();
            if (preview_height)
              $("#text").height(preview_height);
          }
          autoResizeText();
          $(window).resize(autoResizeText);
        </py:if>
        <py:if test="sidebyside and not diff">
          $("#text").autoPreview("${href.wiki_render()}", {
              realm: "${page.resource.realm}", id: "${page.resource.id}"
            }, function(textarea, text, rendered) {
              $("#preview div.wikipage").html(rendered);
              autoResizeText();
          });
        </py:if>
      });
    </script>
  </head>

  <body>
    <div id="content" class="wiki"
       py:with="preview_or_review = action == 'preview' and (not diff or changes[0].diffs)">
      <div class="trac-topnav" py:if="sidebyside or preview_or_review" py:choose="">
        <a py:when="sidebyside" href="#changeinfo"
          title="Go to Save, Preview, Review or Cancel buttons">Actions</a>
        <a py:when="diff" href="#info" title="See the diffs">Review</a>
        <a py:otherwise="" href="#info" title="See the preview">Preview</a>
        &darr;
      </div>
      <h1>Editing ${name_of(page.resource)}</h1>
      <div py:if="merge" class="system-message">
        <p>Someone else has modified that page since you started your edits.</p><br />
        <p i18n:msg=""><b>If you save right away, you risk to revert those changes</b>
        (highlighted below as deletions).</p><br />
        <p i18n:msg="">Please review all those changes and manually merge them with your
        own changes. <br />
        If you're unsure about what you're doing, please press <tt>Cancel</tt>
        (losing your changes) and start editing the latest version of the page
        again.</p>
      </div>

      <!--!

      Normal preview mode, edit form followed by preview:

       | [xi:include "wiki_edit_form.html"                  ]
       |
       | == Preview ==
       |
       | [.Revision #info...................................]
       |
       | [.....#preview.....................................]


      Side-by-side edit/preview mode:

       | [.Revision #info...................................]
       |
       | == Preview ==
       |                               [......#preview......]
       | [xi:include "wiki_edit_form.html"]

      (the  #preview will float at the right of the edit form's textarea)

      -->
      <py:if test="not sidebyside"><xi:include href="wiki_edit_form.html" /></py:if>
      <py:choose test="action">
        <py:when test="'preview'">
          <table id="info" summary="Revision info">
            <tbody>
              <tr><th scope="col" i18n:msg="version, author">
                Change information for future version ${page.version+1} (modified by $author):
              </th></tr>
              <tr><td class="message" xml:space="preserve">
                ${wiki_to_html(context(page.resource(version=None)), comment)}
              </td></tr>
            </tbody>
          </table>
          <div class="${sidebyside and 'sidebyside preview-right'}" py:choose="">
            <div class="trac-nav" py:if="not sidebyside and preview_or_review">
              <a href="#content" title="Go to the editor">Edit</a> &uarr;
            </div>
            <h2 py:choose="">
              <py:when test="preview_or_review and diff">Review Changes</py:when>
              <py:when test="preview_or_review">Preview</py:when>
              <py:otherwise>No changes</py:otherwise>
            </h2>
            <div id="preview">
              <div py:when="diff" class="diff">
                <xi:include href="diff_div.html" py:with="no_id=True" />
              </div>
              <div py:otherwise="" class="wikipage" xml:space="preserve">
                ${wiki_to_html(context(page.resource), page.text)}
              </div>
            </div>
            <div py:if="not sidebyside and page.text" class="trac-nav">
              <a href="#changeinfo"
                title="Go to Save, Preview, Review or Cancel buttons">Actions</a> &uarr;
            </div>
          </div>
        </py:when>
        <py:when test="'collision'">
          <div class="system-message">
            Sorry, this page has been modified by somebody else since you started
            editing. Your changes cannot be saved.
          </div>
        </py:when>
      </py:choose>
      <py:if test="sidebyside"><xi:include href="wiki_edit_form.html" /></py:if>
    </div>
  </body>
</html>
